package com.bear.fastrepair.mvvm.ui.employee.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bear.fastrepair.base.BaseViewHolder
import com.bear.fastrepair.databinding.ItemBillLogBinding
import com.bear.fastrepair.entity.BillInfo

class BillAdapter(private val data: List<BillInfo>) :
    RecyclerView.Adapter<BillAdapter.ViewHolder>() {
    inner class ViewHolder(private val binding: ItemBillLogBinding) :
        BaseViewHolder<BillInfo>(binding.root) {
        @SuppressLint("SetTextI18n")
        override fun bind(item: BillInfo, index: Int) {
            binding.logTime.text = "${item.createTime} ${item.billTypeText}${item.price}"
            binding.logContent.text = "工程师${item.employeeName}: ${item.remark}"
        }
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(
            ItemBillLogBinding.inflate(
                LayoutInflater.from(parent.context),
                parent,
                false
            )
        )
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.bind(data[position], position)
    }

    override fun getItemCount(): Int {
        return data.size
    }
}